package one;

import java.util.Scanner;

public class test9715 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int[] array = new int[N];
        for(int i=0;i<N;i++){
            array[i]=input.nextInt();
        }
        int max=0;
        int temp=0;
        for(int i=0;i<N;i++){
            int min=array[i];
            for(int j=i;j<N;j++){
                min=min>array[j]?array[j]:min;
                temp=min*(j-i+1);
                max=max>temp?max:temp;
            }
        }
        System.out.println(max);
    }
}
